<?php

// 查看一个竞秀活动的前十名照片。
if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

if(empty($_G['uid'])){
	showmessage('to_login', '', array(), array('showmsg' => true, 'login' => 1));
}

require_once libfile('function/database');
require_once libfile('function/vote');

$aid = getgpc('aid');
$uid = getgpc('uid');
$coin = getgpc('bid_gold_coin');

if (!(empty($aid) || empty($uid) || empty($coin) || $coin <= 0 )) {
	if ($uid == $_G['uid'] ) {
		$user_gold_coin = get_gold_coin();
		if ($user_gold_coin >= $coin) {
			$sql = ' update '.DB::table('vote_user_count').' set bid_gold_coin = bid_gold_coin + '.$coin.' where aid = '.intval($aid).' and uid = '.intval($uid);
			$count = DB::query($sql);
			if ($count > 0){
				updatemembercount($_G['uid'], array(get_gold_coin_field() => (0 - $coin)), true, 'REB', $_G['uid']);
			}
		}
		else {
			$message = lang('bid/template', 'not_enough_rebid_gold_coin',
				array('user_gold_coin' => $user_gold_coin, 'rebid_coin' => $coin));
			showmessage($message, '', array(), array('showmsg' => true, 'alert' => 'error'));
		}
	}
	else {
		$message = lang('bid/template', 'no_rebid_others');
		showmessage($message, '', array(), array('showmsg' => true, 'alert' => 'error'));
	}
}

require_once 'user.php';
?>